﻿/**
 * @author Flower
 * @description this is an Auth tool
 */

import Cookies from 'js-cookie'
//for local mock
//w8f5d6IBVhZECj541jkQu8U
Cookies.set('vUserId', 'w8f5d6IBVhZECj541jkQu8U');
Cookies.set('Uid', '46787646');
Cookies.set('vTelephone', '17739308445');

// Cookies.set('vUserId', 'xsH9JvVUUElEDzp33j0QuMY');
// Cookies.set('Uid', '46787304');
// Cookies.set('vTelephone', '18516555321');

// Cookies.set('vUserId', 'lMeiJ/5UBBsrDjh82jdD7MeF8jUsSmIiy68QwuyR6OqNDKPjkfmeRjnD1PDUTTZVKA')
// Cookies.set('Uid', '18803623');
// Cookies.set('vTelephone', '18955127413');

// Cookies.set('vUserId', 'w8KuIqRaA0p9W2t2jD5EucODpmcrSDQiw6xLkr6R7evcDfDkkfnJFjnG2v/cSTZWLg')
// Cookies.set('Uid', '46787615');
// Cookies.set('vTelephone', '13564608859');
// Cookies.set('vUserId', 'ysCodPFaAB18Czt41zoVucKEnTAqTD9yxqBGlQ')
// Cookies.set('Uid', '467865852');
// Cookies.set('vTelephone', '13564608859');

function getUserAuth() {
    let userAuth = {};
    userAuth['UserId'] = Cookies.get('vUserId') || '';
    userAuth['Uid'] = Cookies.get('Uid') || '';
    userAuth['Telephone'] = Cookies.get('vTelephone') || '';
    userAuth['UDID'] = localStorage.getItem('mUDID') || '';
    return userAuth;
}

export default {
    getUserAuth: getUserAuth,
    isLogin() {
        return !!getUserAuth().UserId
    },
    getUserId(){
      return getUserAuth().UserId;
    },
    getUid() {
      return getUserAuth().Uid
    },
    setUserId(userId, uId){
      console.log('set userId', userId)
      Cookies.set('vUserId',userId) 
      Cookies.set('Uid',uId) 
    },
    setUdid(udid){
      localStorage.setItem('mUDID', udid);
    }
}
